/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ntb.controllers;

import javax.servlet.http.Cookie;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LogoutAction extends Action {

    @Override
    public ActionForward execute(ActionMapping mapping,
            ActionForm form,
            HttpServletRequest request,
            HttpServletResponse response) {
        // Delete all remember cookie
        Cookie cookie = new Cookie("userid", "");
        cookie.setMaxAge(0);
        response.addCookie(cookie);

        cookie = new Cookie("remembercode", "");
        cookie.setMaxAge(0);
        response.addCookie(cookie);

        // Delete all session
        request.getSession().invalidate();
        return mapping.findForward("login");
    }
}
